﻿@model MvcCmsProjectTracker.ViewModels.ProjectCategoryViewModel
<div id="categories">
    @if (Model.Categories.Count > 0)
    { 
        <table id="category-table">
            <tr>
                <th>
                </th>
                <th>
                    Category
                </th>
            </tr>
            @foreach (var item in Model.Categories)
            { <tr id="#row-@item.CategoryID ">
               <td>
                   @Ajax.ActionLink("Delete", "DeleteCategory", new { id = item.CategoryID }, new AjaxOptions { HttpMethod="POST", UpdateTargetId = "categories", OnFailure = "handleFailure", Confirm = "Are you sure you want to delete this Category?" })
               </td>
               <td>
                   @item.Name
               </td>
           </tr>
            }
        </table>
    }
    @using (Ajax.BeginForm("AddCategory", "Project", new { id = Model.ProjectID }, new AjaxOptions { HttpMethod="POST", UpdateTargetId = "categories", OnFailure = "handleFailure" }))
    { 
        <label for="name">
            Category Name:</label>
        @Html.TextBox("categoryname", "")
        <input type="submit" value="Submit" />
    }
    @Html.Partial("ControlsProjectTracker/Message", Model)
</div>
